package db;
import java.sql.Connection;
import java.sql.DriverManager;

public class MySQLSingleton {
	private Connection connection;
	private String user="root";
	private String password="";
	private String url="localhost";
	private String database="cookme";
	
	private static MySQLSingleton mySQLSingleton; 
	
	private MySQLSingleton() throws Exception{
		Class.forName("com.mysql.jdbc.Driver");
		connection=DriverManager.getConnection("jdbc:mysql://"+url+"/"+database+"?user="+user+"&password="+password+"&zeroDateTimeBehavior=convertToNull");
	}
	
	public static Connection getInstance() throws Exception{
		if( MySQLSingleton.mySQLSingleton == null){
			MySQLSingleton.mySQLSingleton = new MySQLSingleton();
		}
		return MySQLSingleton.mySQLSingleton.connection;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getDatabase() {
		return database;
	}

	public void setDatabase(String database) {
		this.database = database;
	}
}
